//
//  ICMCellPartCell.m
//  ICrEAM
//
//  Created by rainimute on 16/11/22.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMCellPartCell.h"

@implementation ICMCellPartCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.stateButton setImage:[UIImage imageNamed:Btn_Activity_Notchoose] forState:UIControlStateNormal];
    [self.stateButton setImage:[UIImage imageNamed:Appointment_ActivityChoose] forState:UIControlStateSelected];
    [ICrEAMTool createAndAddBiggerButtonForButton:self.stateButton andSEL:@selector(stateButtonAction:) target:self addTop:2 bottom:2 left:2 right:2 inView:self];
}

#pragma mark 点击选择按钮
- (IBAction)stateButtonAction:(id)sender {
    self.stateButton.selected = !self.stateButton.selected;
    if ([self.delegate respondsToSelector:@selector(didSelectedStateButtonWithPartCode:andButtonState: WithActCode:)]) {
        [self.delegate didSelectedStateButtonWithPartCode:self.partIdLabel.text andButtonState:self.stateButton.isSelected WithActCode:self.ACTIVITY_CODE];
    }
}

#pragma mark 根据model设值
- (void)setupPartsCellWithPartsModel:(ICMProxyActivityPartsModel *)partsModel  WithExistDic:(NSMutableDictionary *)dic{
    self.ACTIVITY_CODE = partsModel.ACTIVITY_CODE;
    self.partNameLabel.text = partsModel.PART_NAME;
    self.partIdLabel.text = partsModel.PART_NO;
    self.partCountLabel.text = partsModel.PART_QUANTITY;
    NSMutableDictionary *dic1 = [dic objectForKey:partsModel.ACTIVITY_CODE];
    NSMutableDictionary *dic2 = [dic1 objectForKey:@"PANParts"];
    NSNumber *num = [dic2 objectForKey:partsModel.PART_NO];
    self.stateButton.selected = [num boolValue];
    
}

@end
